package com.hxx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxx.entity.DailyTrainEntity;
import com.hxx.mapper.DailyTrainMapper;
import com.hxx.service.DailyTrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DailyTrainServiceImpl extends ServiceImpl<DailyTrainMapper, DailyTrainEntity>
        implements DailyTrainService {
    @Autowired
    private DailyTrainMapper dailyTrainMapper;
    @Override
    public Page<DailyTrainEntity> listPage(Page<DailyTrainEntity> page, DailyTrainEntity entity) {
        return dailyTrainMapper.selectPage(page,new LambdaQueryWrapper<DailyTrainEntity>()
                .eq(entity.getDate()!=null,DailyTrainEntity::getDate,entity.getDate())
                .eq(entity.getType()!=null,DailyTrainEntity::getType,entity.getType())
                .eq(entity.getCode()!=null,DailyTrainEntity::getCode,entity.getCode())
                .orderByDesc(DailyTrainEntity::getCode)
        );
    }
}
